package utils;


import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * Created by zhangbn on 2018/10/23.
 */
public class JedisUtil {

    private final static JedisPool POOL;

    static {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(50);
        config.setMaxIdle(1);
        POOL = new JedisPool(config, "10.82.27.102", 6379, 3000, null, 1);
    }

    /**
     * 从池中获取链接
     */
    public static Jedis getJedis() {
        Jedis jedis = POOL.getResource();
        return jedis;
    }
}
